<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <meta name="layout" content="main" />%{--使用main布局--}%

    <title>帐号管理</title>
</head>
<body>
<div class="row">
    <g:formRemote name="kk" url="[controller: 'account',action: 'addPersonAccount']" before="submitBefore()">
        用户名：<input name="name" type="text"/>
        <br/>
        显示名：<input name="showName" type="text"/>
        <br/>
        密码：<input id="password" name="password" type="password"/>

        重复密码：<input id="repassword" type="password"/>
        <g:select name="personId" from="${people}" optionKey="id" value="${person?.id}" optionValue="name"/>
        <input type="submit" value="add Person Account" />
    </g:formRemote>

    <table class="table">
        <thead>
        <tr>
            <td>索引</td>
            <td>关联人名</td>
            <td>用户名</td>
            <td>显示名</td>
            <td>操作</td>
        </tr>
        </thead>
        <g:each in="${accounts}" var="account" status="st">
            <tr>
                <td>${st}</td>
                <td>${account.person.name}</td>
                <td>${account.name}</td>
                <td>${account.showName}</td>
                <td>
                    <g:remoteLink controller="account" action="removeAccount" params="[id:account.id]"
                                  onSuccess="removeSuccess(account.name)">删除</g:remoteLink> </td>
            </tr>
        </g:each>
    </table>
</div>

<r:script>

    function submitBefore(){
        if ($('#password').val() != $('#repassword').val()) {
            alert('两次密码的输入不一样');
            return false;
        }
        return true;
    }


</r:script>


</body>
</html>
